/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2014-6-10         luwei
 */

package com.tianci.appstore.utils;

import com.coocaa.launcher.framework.sidebar.item.ItemFactory.ITEM;
import com.coocaa.x.framework.app.CoocaaActivity;
import com.coocaa.x.framework.app.CoocaaApplication;
import com.coocaa.x.framework.utils.LogUtils;
import com.tianci.appstore.R;

import java.util.HashMap;


public class SkyConstants {
    public static final int SUBSORTCOUNT = 3;
    public static final long BTOK = 1024;
    public static final long KTOM = 1024;
    public static final long BTOM = 1024 * 1024;
    public static final String ICON_EXT = "icon";
    public static final int PAGECOUNT = 12;
    public static final String REMOTE_CONTROL = "遥控器";
    public static final String HAND_SHANK = "游戏手柄";
    public static final String MOUSE = "鼠标";
    public static final String MOBLIE = "手机";
    public static final String GUN = "枪";
    public static final String INDUCTION_LEAP_MOTION = "感应式体感";
    public static final String CONTROL_LEAP_MOTION = "操控式体感";
    public static final String GAME_CENTER_ALPHA_BG1 = "game_center_alpha_bg1";
    public static final String GAME_CENTER_ALPHA_BG2 = "game_center_alpha_bg2";
    public static final String GAME_CENTER_ALPHA_BG3 = "game_center_alpha_bg3";

    public static int shadowWidth;
    public static int shadowChildWidth;
    public static int blockSpacing;
    public static int mainBlockWidth;

    public static final long THREE_DAY = 3 * 24 * 60 * 60 * 1000;
    public static final long WEEK = 7 * 24 * 60 * 60 * 1000;

    private final static HashMap<String, Integer> ICON_MAP = new HashMap<String, Integer>();
    private final static HashMap<String, Integer> STRING_MAP = new HashMap<String, Integer>();

    public static int iconWidth;
    public static int cornerIconWidth;
    public static int toastTextSize;

    public static final HashMap<Integer,String> LOG_MAP = new HashMap<Integer, String>();

    static {
        ICON_MAP.put("update", R.drawable.icon_gengxin);
        ICON_MAP.put("manage", R.drawable.icon_xiazaiguanli);
        ICON_MAP.put("uninstall", R.drawable.icon_shanchu);
        ICON_MAP.put("move", R.drawable.icon_sdcard);
        ICON_MAP.put("clear", R.drawable.icon_qingchu);
        ICON_MAP.put("about", R.drawable.icon_about);
        ICON_MAP.put("speed", R.drawable.icon_speed);
        ICON_MAP.put("more", R.drawable.icon_more_manage);
        ICON_MAP.put("scan", R.drawable.icon_scan);
        ICON_MAP.put("autostart", R.drawable.icon_autostart);
        ICON_MAP.put("remote_install", R.drawable.icon_remote_install);
        ICON_MAP.put(REMOTE_CONTROL, R.drawable.gc_detail_remote);
        ICON_MAP.put(HAND_SHANK, R.drawable.gc_detail_joystick);
        ICON_MAP.put(MOUSE, R.drawable.gc_detail_mouse);
        ICON_MAP.put(MOBLIE, R.drawable.gc_detail_phone);
        ICON_MAP.put(GUN,R.drawable.gc_detail_gun);
        ICON_MAP.put(INDUCTION_LEAP_MOTION, R.drawable.gc_detail_kinect);
        ICON_MAP.put(CONTROL_LEAP_MOTION, R.drawable.gc_detail_camera);
        ICON_MAP.put(GAME_CENTER_ALPHA_BG1, R.drawable.game_center_alpha_bg1);
        ICON_MAP.put(GAME_CENTER_ALPHA_BG2, R.drawable.game_center_alpha_bg2);
        ICON_MAP.put(GAME_CENTER_ALPHA_BG3, R.drawable.game_center_alpha_bg3);
        ICON_MAP.put(ITEM.APP_CIRCLE.toString(), R.drawable.launcher_app_circle);
        ICON_MAP.put(ITEM.MOVIE.toString(), R.drawable.launcher_icon_movie);
        ICON_MAP.put(ITEM.MULTI_SCREEN.toString(), R.drawable.launcher_icon_tdc);
        ICON_MAP.put(ITEM.SETTING.toString(), R.drawable.launcher_icon_setting);
        ICON_MAP.put(ITEM.SOURCE.toString(), R.drawable.launcher_icon_source);
        ICON_MAP.put(ITEM.THEME.toString(), R.drawable.launcher_icon_theme);
        ICON_MAP.put(ITEM.EXTRAL_USB.toString(), R.drawable.launcher_icon_usb);
        ICON_MAP.put(ITEM.WALLPAPER.toString(), R.drawable.launcher_icon_theme);
        ICON_MAP.put(ITEM.ABOUT_US.toString(), R.drawable.launcher_icon_set_about);
        ICON_MAP.put(ITEM.AUTO_START.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.BACK_EXIT.toString(), R.drawable.launcher_set_icon_back);
        ICON_MAP.put(ITEM.DEFAULT_LAUNCHER.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.DEVICE_INFO.toString(), R.drawable.launcher_icon_set_ifo);
        ICON_MAP.put(ITEM.TV_SETTING.toString(), R.drawable.launcher_icon_set_ifo);
        ICON_MAP.put(ITEM.UPDATE.toString(), R.drawable.launcher_icon_set_update);
        ICON_MAP.put(ITEM.NET_SETTING.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.WIFI_SETTING.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.SYS_SETTING.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.SYS_UPGRADE.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.RECOVERY.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.LOCAL_INFO.toString(), R.drawable.launcher_icon_set_settable);
        ICON_MAP.put(ITEM.GAME_CENTER.toString(), R.drawable.launcher_icon_game_center);
        ICON_MAP.put(ITEM.INNER_WALLPAPER.toString(), R.drawable.launcher_icon_theme);
        ICON_MAP.put(ITEM.LOCAL_WALLPAPER.toString(), R.drawable.launcher_icon_usb);

        ICON_MAP.put("0",R.drawable.corner_dot);
        ICON_MAP.put("1",R.drawable.corner_green_bg);
        ICON_MAP.put("2",R.drawable.corner_orange_bg);
        ICON_MAP.put("3",R.drawable.corner_purple_bg);
        ICON_MAP.put("4",R.drawable.corner_red_bg);
        ICON_MAP.put("5",R.drawable.corner_word_bg);




        STRING_MAP.put(ITEM.APP_CIRCLE.toString(), R.string.left_side_app_circle);
        STRING_MAP.put(ITEM.MOVIE.toString(), R.string.left_side_movie);
        STRING_MAP.put(ITEM.MULTI_SCREEN.toString(), R.string.left_side_qrcode);
        STRING_MAP.put(ITEM.SETTING.toString(), R.string.left_side_launcher_setting);
        STRING_MAP.put(ITEM.SOURCE.toString(), R.string.left_side_source);
        STRING_MAP.put(ITEM.SPEED_UP.toString(), R.string.main_speed);
        STRING_MAP.put(ITEM.THEME.toString(), R.string.left_side_theme);
        STRING_MAP.put(ITEM.EXTRAL_USB.toString(), R.string.left_side_usb);
        STRING_MAP.put(ITEM.WALLPAPER.toString(), R.string.left_side_wallpaper);
        STRING_MAP.put(ITEM.ABOUT_US.toString(), R.string.setting_about_us);
        STRING_MAP.put(ITEM.AUTO_START.toString(), R.string.setting_auto_start);
        STRING_MAP.put(ITEM.BACK_EXIT.toString(), R.string.setting_back_exit);
        STRING_MAP.put(ITEM.DEFAULT_LAUNCHER.toString(), R.string.setting_default_launcher);
        STRING_MAP.put(ITEM.DEVICE_INFO.toString(), R.string.setting_device_info);
        STRING_MAP.put(ITEM.TV_SETTING.toString(), R.string.setting_tv_setting);
        STRING_MAP.put(ITEM.UPDATE.toString(), R.string.setting_update);
        STRING_MAP.put(ITEM.NET_SETTING.toString(), R.string.setting_net_setting);
        STRING_MAP.put(ITEM.WIFI_SETTING.toString(), R.string.setting_wifi_setting);
        STRING_MAP.put(ITEM.SYS_SETTING.toString(), R.string.setting_sys_setting);
        STRING_MAP.put(ITEM.SYS_UPGRADE.toString(), R.string.setting_sys_upgrade);
        STRING_MAP.put(ITEM.RECOVERY.toString(), R.string.setting_recovery);
        STRING_MAP.put(ITEM.LOCAL_INFO.toString(), R.string.setting_local_info);
        STRING_MAP.put(ITEM.GAME_CENTER.toString(), R.string.game_center);
        STRING_MAP.put(ITEM.INNER_WALLPAPER.toString(), R.string.setting_inner_wallpaper);
        STRING_MAP.put(ITEM.LOCAL_WALLPAPER.toString(), R.string.setting_custom_wallpaper);

        LOG_MAP.put(0,"A");
        LOG_MAP.put(1,"B");
        LOG_MAP.put(2,"C");
    }

    public static void initResolution() {
        shadowWidth = CoocaaActivity.Div(CoocaaApplication.getContext().getResources().getDimensionPixelSize(R.dimen.shadow_width));
        LogUtils.d("corner","shadowwidth is " + shadowWidth);
        shadowChildWidth = CoocaaActivity.Div(CoocaaApplication.getContext().getResources().getDimensionPixelSize(R.dimen.shadow_child_width));
        blockSpacing = CoocaaActivity.Div(CoocaaApplication.getContext().getResources().getDimensionPixelSize(R.dimen.block_spacing));
        mainBlockWidth = CoocaaActivity.Div(CoocaaApplication.getContext().getResources().getDimensionPixelSize(R.dimen.main_block_width));
        iconWidth = CoocaaActivity.Div(CoocaaApplication.getContext().getResources().getDimensionPixelSize(R.dimen.icon_width));
        cornerIconWidth = CoocaaActivity.Div(CoocaaApplication.getContext().getResources().getDimensionPixelSize(R.dimen.corner_icon_width));
        toastTextSize = CoocaaActivity.Dpi((int) CoocaaApplication.getContext().getResources().getDimension(R.dimen.toast_text_size));
    }

    public static Integer getIconId(String key) {
        if (ICON_MAP.get(key) == null) {
            return R.drawable.pic_nopic;
        }
        return ICON_MAP.get(key);
    }

    public static Integer getStringId(String key) {
        if (STRING_MAP.get(key) == null) {
            return R.string.left_side_app_circle;
        }
        return STRING_MAP.get(key);
    }

    public static int Div(int x) {
        return CoocaaApplication.Div(x);
    }

    public static int Dpi(int x) {
        return CoocaaApplication.Dpi(x);
    }

}
